package com.zzq.my.jetpacks.jectpackapp.ui.act

import android.os.Build
import android.os.Bundle
import android.view.View
import androidx.annotation.RequiresApi
import androidx.core.content.ContextCompat
import by.kirich1409.viewbindingdelegate.viewBinding
import com.aisier.architecture.base.BaseActivity
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.zzq.my.jetpacks.jectpackapp.R
import com.zzq.my.jetpacks.jectpackapp.databinding.Activity14Binding
import com.zzq.my.jetpacks.jectpackapp.ui.fragment.MyBottomSheetDialog
import kotlinx.coroutines.Job

/**
 * 描述：Android NestedScrollView滚动到顶部固定子View悬停挂靠粘在顶端
 * 作者：zhuangzeqin
 * 时间: 2022/1/18-17:04
 * 邮箱：zzq@eeepay.cn
 * 备注:
 */
class Activity10 : BaseActivity(R.layout.activity_14), View.OnClickListener {
    private val binding by viewBinding(Activity14Binding::bind)
    var mCountdownJob: Job? = null//倒计时

    /**
     * 初始化数据
     */
    override fun initData() {

    }

    /**
     * 初始化操作
     */
    @RequiresApi(Build.VERSION_CODES.O)
    override fun initView() {
        binding.tvTimer.setOnClickListener {
//            launchKt {
////                mCountdownJob = it.countDownCoroutines(60,this, onStart = {
////                    // 倒计时开始
////                    binding.tvTimer.isEnabled = false
////                }, onTick = {
////                    binding.tvTimer.text = "${it}s后重发"
////                }, onFinish = {
////                    binding.tvTimer.isEnabled = true
////                    // 倒计时结束，重置状态
////                    binding.tvTimer.text = "发送验证码"
////                })
///*                it.countDownCoroutines2(60, this) {
//                    onStart = {
//                        // 倒计时开始
//                        binding.tvTimer.isEnabled = false
//                    }
//                    onFinish = {
//                        binding.tvTimer.isEnabled = true
//                        // 倒计时结束，重置状态
//                        binding.tvTimer.text = "发送验证码"
//                    }
//                    onTick = {
//                        binding.tvTimer.text = "${it}s后重发"
//                    }
//                }*/
//
//                val str = "abc"
//                val dslString = str.strDSL {
//                 append("123")
//                 append("456")
//                }
//
//                println(dslString)
//
//                binding.tvTimer.text = dslString
//
//               val user  =  createUser {
//                    name = "小海狮"
//                    age = 25
//                }
//                val user2  =  createUser {
//                    name = "小海狮2"
//                    age = 252
//                }
//
//               val list  = addDsl<User> {
//                    add(user)
//                    add(user2)
//                }

           val b =  Bundle().clone() as Bundle//Bundle  clone 克隆一份数据


//
//
//                println(user)
//                println(list)
//            }

//            initDialog()

            MyBottomSheetDialog().show(supportFragmentManager,"MyBottomSheetDialog")

        }
    }

    private fun initDialog()
    {
//        BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this);
//        bottomSheetDialog.setContentView(R.layout.dialog_goods_sku_layout);
//        //给布局设置透明背景色，让图片突出来
//        bottomSheetDialog.getDelegate().findViewById(android.support.design.R.id.design_bottom_sheet)
//            .setBackgroundColor(getResources().getColor(android.R.color.transparent));
//        bottomSheetDialog.show();

       val bottomSheetDialog =  BottomSheetDialog(this)
        bottomSheetDialog.setContentView(R.layout.dialog_goods_sku_layout)
        bottomSheetDialog.delegate.findViewById<View>(R.id.design_bottom_sheet)?.setBackgroundColor(ContextCompat.getColor(this,android.R.color.transparent))
        bottomSheetDialog.show()
        bottomSheetDialog.setCanceledOnTouchOutside(true)

    }

    /**
     * 初始化点击事件操作
     */
    override fun eventOnClick() {

    }

    override fun onClick(v: View) {

    }

}